package array.Binary_Search;
import org.junit.Test;


public class base {
    @Test
    public void t1(){
        //二分查找
        int[] arr=new int[]{1,2,2,3,4,8,12,13,24,36,78} ;
        int low=0;
        int high=arr.length-1;
        int mid=(low+high)/2;
        while(low<=high){
            mid=(low+high)/2;
            if(arr[mid]<24){
                low=mid+1;
            } else if (arr[mid]>24) {
                high=mid-1;
            } else if (arr[mid]==24) {
                System.out.println(mid);
                break;
            }
        }
        System.out.println(-1);
    }
}
